package com.etc.action.baoxiao;

import java.util.ArrayList;
import java.util.List;

import com.etc.po.BaoXiaoJiLu;
import com.etc.po.PageBean;
import com.etc.service.baoxiao.BaoXiaoJiLuService;
import com.opensymphony.xwork2.ActionSupport;

/**
 * 对报销记录信息的管理
 * @author 飞
 *
 */
public class BaoXiaoJiLuAction extends ActionSupport{
    
	//创建一个报销审批记录服务对象
	public BaoXiaoJiLuService  bxjlservice=new BaoXiaoJiLuService();
	
	//声明一个报销记录列表
	private List<BaoXiaoJiLu> bxjlist;
	
	//从业面获取信息
	private BaoXiaoJiLu  condition;
	
	//传输数据到页面
	private BaoXiaoJiLu  bxjl;
	
	//创建一pagebena对象
	private PageBean pb=new PageBean();
	
	//页数控制		
	private String a="";
	
	//页数控制
	private String b="";
	
	
	public String show(){
		int t=bxjlservice.getcount();
		
		System.out.println(t);
		pb.setTotalRows(t);
		
		
		pb.setTotalPages((t+pb.getPageSize()-1)/pb.getPageSize());
		
		if(pb.getPageNow()<1){
			pb.setPageNow(1);
			a="已是第一页";
		}else if(pb.getPageNow()>pb.getTotalPages()){
			pb.setPageNow(pb.getTotalPages());
			b="已是最后一页";
			
		}
		bxjlist = bxjlservice.getAllInfo(pb);
		 System.out.println(bxjlist.size());
		return "baoxiao-shenpi-jilu";
		
	}
	
	public String getJilu(){
		bxjl=bxjlservice.getBaoXiaoJiLu(condition.getBxspjl_id());
		return "detail";
	}
	
	/**
	 * 对报销记录添加处理
	 * @return
	 */
	public String add(){
		
		boolean mark=bxjlservice.add(bxjl);
		
		if(mark){
			
			System.out.println("报销记录添加成功");
		}else{
			
			System.out.println("报销记录添加失败");
		}
		//bxjlist=bxjlservice.getAllBaoXiaoJiLu();
		
		return "添加页面";
	}
    
	/**
	 * 对报销记录修改处理
	 * @return
	 */
	public String update(){
		
		boolean mark=bxjlservice.update(bxjl);
		
		if(mark){
			
			System.out.println("报销记录修改成功");
		}else{
			
			System.out.println("报销记录修改失败");
		}
		
		//bxjlist=bxjlservice.getAllBaoXiaoJiLu();
		
		return "修改页面" ;
	}
   
	/**
	 * 加载报销记录信息
	 * @return
	 */
	/*
   public String load(){
	   
	   bxjl=bxjlservice.getbxjlinfo(condition.getBxspjl_id());
	   
	   return "修改页面";
	   
   }*/
   
   /**
    * 对报销记录信息删除处理
    * @return
    */
   public String deltete(){
		
		boolean mark=bxjlservice.delete(bxjl);
		
		if(mark){
			
			System.out.println("报销记录删除成功");
		}else{
			
			System.out.println("报销记录删除失败");
		}
		
		//bxjlist=bxjlservice.getAllBaoXiaoJiLu();
		
		return "列表页面" ;
	}

   /**
    * 	//默认进入方法
    */
	@Override
	public String execute() throws Exception {
		
		//bxjlist=bxjlservice.getAllBaoXiaoJiLu();
		
		return "列表页面";
	}
	
	

	public BaoXiaoJiLu getCondition() {
		return condition;
	}

	public void setCondition(BaoXiaoJiLu condition) {
		this.condition = condition;
	}

	public BaoXiaoJiLu getBxjl() {
		return bxjl;
	}

	public void setBxjl(BaoXiaoJiLu bxjl) {
		this.bxjl = bxjl;
	}



	public List<BaoXiaoJiLu> getBxjlist() {
		return bxjlist;
	}


	public void setBxjlist(List<BaoXiaoJiLu> bxjlist) {
		this.bxjlist = bxjlist;
	}


	public BaoXiaoJiLuService getBxjlservice() {
		return bxjlservice;
	}

	public void setBxjlservice(BaoXiaoJiLuService bxjlservice) {
		this.bxjlservice = bxjlservice;
	}

	public PageBean getPb() {
		return pb;
	}

	public void setPb(PageBean pb) {
		this.pb = pb;
	}

	public String getA() {
		return a;
	}

	public void setA(String a) {
		this.a = a;
	}

	public String getB() {
		return b;
	}

	public void setB(String b) {
		this.b = b;
	}
	
	

}